<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@page import="com.ares.service.bean.BeanObjetivo" %>
<%@page import="com.ares.service.bean.BeanMeta" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <title>Sistema Gestión de Desempeño</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />-->
        <link href="<%=request.getContextPath()%>/css/miestilo.css" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.3.min.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/js/util.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/js/sevde.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/js/prototype.js"></script>
    </head>

    <body
        onunload="
                    javascript:window.opener.document.getElementById('btnNuevoObjetivo').disabled=false;
                    javascript:window.opener.document.getElementById('btnModificarObjetivo').disabled=false;
                    javascript:window.opener.document.getElementById('btnEliminarObjetivo').disabled=false;
                    javascript:window.opener.document.getElementById('btnNuevaMeta').disabled=false;
                    javascript:window.opener.document.getElementById('btnModificarMeta').disabled=false;
                    javascript:window.opener.document.getElementById('btnEliminarMeta').disabled=false;
            ">
        <html:form action="evaluacion">
            <input type="hidden" name="method" />
            <input type="hidden" name="valor" />
            <table>
                <tr>
                    <td style="background: #1F497D ; color: #ffffff " class="labelCampos" >
                        Descripción Objetivo
                    </td>
                </tr>

                <tr>
                    <td>
                        <textarea cols="62" rows="10" id="strdesobjetivo" onkeydown="valida_longitud()" onkeyup="valida_longitud()" class="textarea"></textarea>
                        <!--html:textarea cols="62" rows="10" property="strdesobjetivo" styleId="strdesobjetivo"  onkeydown="valida_longitud()" onkeyup="valida_longitud()" styleClass="textarea" >/html:textarea-->
                    </td>
                </tr>

                <tr>
                    <td colspan="4" class="glosa">
                        <font color="#1F497D"><bean:message key="glosa.tamaño.obj.metas" /></font>
                    </td>              
                </tr>

                <tr>
                    <td colspan="4" class="glosa">
                        <font color="#1F497D"><bean:message key="glosa.sinllenar.obj" /></font>
                    </td>
                </tr>

                <tr>
                    <td>
                        <input type="button" value="Aceptar" style="background:#AAAAAA" onclick="agregar();" />
                    </td>
                </tr>
            </table>
        </html:form>

        <script type="text/javascript">            
            function agregar(){
                var desObj = document.forms[0].strdesobjetivo.value;             
                if(trim(desObj).length >0){
                    var id = '<%=request.getParameter("id")%>';                    
                    var tabla = window.opener.document.getElementById("tablaColap");
                    var idUsu = '<c:out value="${sessionScope.usuarioSurb.strNombre}" />';          
                    setTabla(tabla);
                    //fillObjetivo(id,desObj,idUsu,tipo);
                    fillObjetivo(id,desObj,idUsu );
                    cerrar();
                }
            }

            function trim(obj){
                return obj.replace(/^\s+|\s+$/g,'');
            }
            
            contenido_textarea = "";
            num_caracteres_permitidos = 255;

            function valida_longitud(){
                num_caracteres = document.forms[0].strdesobjetivo.value.length;
                
                if (num_caracteres > num_caracteres_permitidos){
                    document.forms[0].strdesobjetivo.value = contenido_textarea;
                }else{                    
                    contenido_textarea = document.forms[0].strdesobjetivo.value;
                }
            }
            function cerrar(){
            	javascript:window.opener.document.getElementById('btnNuevoObjetivo').disabled=false;
	            javascript:window.opener.document.getElementById('btnModificarObjetivo').disabled=false;
	            javascript:window.opener.document.getElementById('btnEliminarObjetivo').disabled=false;
	            javascript:window.opener.document.getElementById('btnNuevaMeta').disabled=false;
	            javascript:window.opener.document.getElementById('btnModificarMeta').disabled=false;
	            javascript:window.opener.document.getElementById('btnEliminarMeta').disabled=false;
            	window.close();
            }
        </script>
    </body>
</html>
